package com.example.springlearn.controller;

import com.example.springlearn.bean.HelloBean;
import com.example.springlearn.service.HelloService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    @Resource
    HelloService helloService;

    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    @ResponseBody
    @GetMapping(value = "/getById/{id}")
    public HelloBean getHelloBeanById(@PathVariable Integer id) {
        return helloService.getHelloBean(id);
    }

    @ResponseBody
    @GetMapping(value = "/all")
    public List<HelloBean> getAll() {
        return helloService.getAllHelloBean();
    }

}
